<?php

/**
 * This is the model class for table "protection_of_vertical_opening".
 *
 * The followings are the available columns in table 'protection_of_vertical_opening':
 * @property integer $id
 * @property integer $properly_protected
 * @property integer $atrium
 * @property integer $fire_door_good_condition
 * @property integer $elevator_opening_protected
 * @property integer $pipe_chase_opening_protected
 * @property integer $aircon_duct_system_with_damper
 * @property integer $dumb_waiter_opening_protected
 * @property integer $garbage_chute_opening_protected
 * @property integer $between_floor_and_glass_curtain_opening_protected
 * @property string $date_last_tested
 * @property integer $inspection_id
 *
 * The followings are the available model relations:
 * @property Inspection $inspection
 */
class ProtectionOfVerticalOpening extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ProtectionOfVerticalOpening the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'protection_of_vertical_opening';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inspection_id', 'required'),
			array('properly_protected, atrium, fire_door_good_condition, elevator_opening_protected, pipe_chase_opening_protected, aircon_duct_system_with_damper, dumb_waiter_opening_protected, garbage_chute_opening_protected, between_floor_and_glass_curtain_opening_protected, inspection_id', 'numerical', 'integerOnly'=>true),
			array('date_last_tested', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, properly_protected, atrium, fire_door_good_condition, elevator_opening_protected, pipe_chase_opening_protected, aircon_duct_system_with_damper, dumb_waiter_opening_protected, garbage_chute_opening_protected, between_floor_and_glass_curtain_opening_protected, date_last_tested, inspection_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inspection' => array(self::BELONGS_TO, 'Inspection', 'inspection_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'properly_protected' => 'Properly Protected',
			'atrium' => 'Atrium',
			'fire_door_good_condition' => 'Fire Door Good Condition',
			'elevator_opening_protected' => 'Elevator Opening Protected',
			'pipe_chase_opening_protected' => 'Pipe Chase Opening Protected',
			'aircon_duct_system_with_damper' => 'Aircon Duct System With Damper',
			'dumb_waiter_opening_protected' => 'Dumb Waiter Opening Protected',
			'garbage_chute_opening_protected' => 'Garbage Chute Opening Protected',
			'between_floor_and_glass_curtain_opening_protected' => 'Between Floor And Glass Curtain Opening Protected',
			'date_last_tested' => 'Date Last Tested',
			'inspection_id' => 'Inspection',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('properly_protected',$this->properly_protected);
		$criteria->compare('atrium',$this->atrium);
		$criteria->compare('fire_door_good_condition',$this->fire_door_good_condition);
		$criteria->compare('elevator_opening_protected',$this->elevator_opening_protected);
		$criteria->compare('pipe_chase_opening_protected',$this->pipe_chase_opening_protected);
		$criteria->compare('aircon_duct_system_with_damper',$this->aircon_duct_system_with_damper);
		$criteria->compare('dumb_waiter_opening_protected',$this->dumb_waiter_opening_protected);
		$criteria->compare('garbage_chute_opening_protected',$this->garbage_chute_opening_protected);
		$criteria->compare('between_floor_and_glass_curtain_opening_protected',$this->between_floor_and_glass_curtain_opening_protected);
		$criteria->compare('date_last_tested',$this->date_last_tested,true);
		$criteria->compare('inspection_id',$this->inspection_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}